package com.bzkj.web.controller.ncc;

import com.bzkj.basicinfo.domain.ncc.NccBasicDept;
import com.bzkj.basicinfo.domain.ncc.dto.NccBasicDeptDto;
import com.bzkj.basicinfo.service.ncc.NccBasicDeptService;
import com.bzkj.common.annotation.LogC;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.domain.R;
import com.bzkj.common.core.page.TableDataInfo;
import com.bzkj.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@Api(tags = "部门信息")
@RestController
@RequestMapping("/ncc")
public class NccBasicDeptController extends BaseController
{

    @Autowired
    private NccBasicDeptService basicDeptService;

    /**
     * NCC部门
     */
    @GetMapping({"/basicDept", "/basicDept/{all}"})
    @PreAuthorize("@ss.hasPermi('ncc:BasicDept:Job')")
    public void nccBillStatusJob(@PathVariable(required = false) String all)
    {
        basicDeptService.updateNccBasicDeptJob(all);
    }


    /**
     * 分页查询部门信息
     *
     * @Author wangzhichao
     * @Date 2024/12/09 13:19:17
     * @Param dto
     */
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:query')")
    @GetMapping("/findNccBasicDeptData")
    @ApiOperation("查询接口")
    public TableDataInfo findNccBasicDeptData(NccBasicDeptDto dto)
    {
        startPage();
        return getDataTable(basicDeptService.findNccBasicDeptData(dto));
    }

    /**
     * 根据pkDept修改部门状态
     *
     * @Author wangzhichao
     * @Date 2024/12/09 13:34:53
     * @Param status
     * @Param pkDept
     */
    @ApiOperation("修改状态接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:stateEdit')")
    @PutMapping("/nccBasicDeptEnableStatusUpdate")
    @LogC(title = "ncc部门信息", businessType = BusinessType.UPDATE,
            tableNames = "ncc_basic_dept", pkFieldNames = "code", content = "' 部门code：'+#code")
    public AjaxResult nccBasicDeptEnableStatusUpdate(@RequestParam(value = "status") String status, @RequestParam("code") String code)
    {
        return basicDeptService.nccBasicDeptEnableStatusUpdate(status, code);
    }


    /**
     * 根据code修改部门信息
     *
     * @Author wangzhichao
     * @Date 2024/12/09 13:44:18
     * @Param entity
     */
    @ApiOperation("修改接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:edit')")
    @PutMapping("/nccBasicDeptDataUpdate")
    @LogC(title = "ncc部门信息", businessType = BusinessType.UPDATE,
            tableNames = "ncc_basic_dept", pkFieldNames = "id", content = "' 部门名称：'+#entity.name")
    public AjaxResult nccBasicDeptDataUpdate(@RequestBody NccBasicDept entity)
    {
        return basicDeptService.nccBasicDeptDataUpdate(entity);
    }

    /**
     * 新增部门信息
     *
     * @Author wangzhichao
     * @Date 2024/12/10 08:54:53
     * @Param entity
     */
    @ApiOperation("新增接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:add')")
    @PostMapping("/nccBasicDeptSave")
    @LogC(title = "ncc部门信息", businessType = BusinessType.INSERT,
            tableNames = "ncc_basic_dept", pkFieldNames = "id", content = "' 部门名称：'+#entity.name")
    public AjaxResult nccBasicDeptSave(@RequestBody NccBasicDept entity)
    {
        return basicDeptService.nccBasicDeptSave(entity);
    }

    /**
     * 根据部门名称查询部门信息
     *
     * @param name
     * @return
     */
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:query')")
    @GetMapping("findDeptListByName")
    @ApiOperation("查询所属部门下拉接口")
    public R findDeptListByName(String name)
    {
        return basicDeptService.findDeptListByName(name);
    }

    /**
     * 定时同步部门信息
     *
     * @return
     */
    @GetMapping("jobMethodExecute")
    public R jobMethodExecute()
    {
        return basicDeptService.jobMethodExecute(false);
    }


}
